Certain events, like the OnSectionFormat event, may get fired more than once in a section. For example, a Details section may fire multiple times for a given record if the program is performing "Keep Section Together" calculations for the report. When you are using VB variables that are supposed to increment once for each record (as when you are calculating a running total), you can have problems maintaining state with these multiple firings.
To prevent these problems, the RDC now enables you to declare Report Variables. Report variables are Crystal variables that you can use in your VB code. Report Variables "understand" what's going on in the report and they increment appropriately. This enables you to do more of your coding than ever in VB and still get the results you expect.
There are three methods you use with report variables.
You use AddReportVariable to declare a Report Variable. The following code declares four Report Variables:
AddReportVariable crRVCurrency, "CurrencyVal" AddReportVariable crRVNumber, "LongVal" AddReportVariable crRVNumber, "DoubleVal" AddReportVariable crRVString, "StringVal"
You use GetReportVariableValue to reference the value in a Report Variable. The following code references the value in the Report Variable, CurrencyVal.
CurVal = GetReportVariableValue("CurrencyVal")
You use SetReportVariableValue to increment a Report Variable. The following code sets the value of the Report Variable CurrencyVal to the value of the expression "CDbl(CurVal) + CDbl(FieldCurrency.Value)".
SetReportVariableValue "CurrencyVal", CDbl(CurVal) + CDbl(FieldCurrency.Value)
Note that you can only use Report Variables at runtime and that you must use double quotes every time you reference such a variable.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |